#include "parserapi.h"

/*******************Configuration Message Parser**********************/
ConfigParser::ConfigParser()
{
    MsgType = new QString();
    BotType = new QString();
    ID = new QString();
    Sensors =new QStringList();
    socketID = new QString();
}

void ConfigParser::msgParse(QString Msg)
{
    *MsgType = QString(Msg.left(cuiHDR_SIZE));
    Msg.remove(0, cuiHDR_SIZE);
    *ID = QString(Msg.left(cuiID_SIZE));
    Msg.remove(0, cuiID_SIZE);
    *BotType = QString(Msg.left(cuiBOT_SIZE));
    Msg.remove(0, cuiBOT_SIZE);
    *Sensors = Msg.split(':');

    *socketID = Sensors->last(); //The last item is actually the socket ID
    Sensors->removeLast();

}

/*******************Sensor Update Message Parser**********************/
SensorParser::SensorParser()
{
    MsgType = new QString();
    SensorData = new QStringList();
}

void SensorParser::msgParse(QString Msg)
{
    *MsgType = QString(Msg.left(cuiHDR_SIZE));
    *SensorData = Msg.split(':');
}

/*******************Acknowledgement Message Parser**********************/
AckParser::AckParser()
{
    MsgType = new QString();
}

void AckParser::msgParse(QString Msg)
{
    *MsgType = QString(Msg.left(cuiHDR_SIZE));
}
